import http from "@/http";
// 人气推荐 /home/recommendProduct/list?pageNum=1&pageSize=5
export const recommendProductApi = (
  pageNum: number,
  pageSize: number
): RES<HomeHotData> =>
  http.get(
    `/home/recommendProduct/list?pageNum=${pageNum}&pageSize=${pageSize}`
  );

//   /mall-admin/home/recommendProduct/update/recommendStatus
// 人气是否推荐
export const recommendStatusApi = (
  ids: number,
  recommendStatus: any
): RES<RecommendStatus> =>
  http.post(
    `/home/recommendProduct/update/recommendStatus?ids=${ids}&recommendStatus=${recommendStatus}`
  );

// 修改推荐排序
export const sortApi = (id: number, sort: number): RES<RecommendStatus> =>
  http.post(`/home/recommendProduct/update/sort/${id}?sort=${sort}&id=${id}`);

// 点击选择商品请求数据
export const ProductListApi = (
  pageNum: number,
  pageSize: number
): RES<ProductData & { list: ProductList }> =>
  http.get(`/product/list?pageNum=${pageNum}&pageSize=${pageSize}`);

// 商品搜索
export const SearchProductListApi = (
  keyword: string | number,
  pageNum: number,
  pageSize: number
): RES<ProductData & { list: ProductList }> =>
  http.get(
    `/product/list?keyword=${keyword}&pageNum=${pageNum}&pageSize=${pageSize}`
  );

// 专题推荐商品添加
// /home/recommendProduct/create
export const ProductCreateApi = (params: any): RES<DeleteData> =>
  http.post(`/home/recommendProduct/create`, params);

// 人气推荐页面筛选搜索

export const ProductSearchApi = (
  pageNum: number,
  pageSize: number,
  productName: string | number,
  recommendStatus: number
): RES<ProductData & { list: ProductList }> =>
  http.get(
    `/home/recommendProduct/list?pageNum=${pageNum}&pageSize=${pageSize}&productName=${productName}&recommendStatus=${recommendStatus}`
  );

// 人气推荐页面删除
// /home/recommendProduct/delete
export const deleteApi = (ids: number): RES<DeleteData> =>
  http.post(`/home/recommendProduct/delete?ids=${ids}`);

// 人气页面checkbox选择
// /home/recommendProduct/update/recommendStatus

export const recommendStatusAllApi = (
  ids: number[],
  recommendStatus: number | string
): RES<DeleteData> =>
  http.post(
    `/home/recommendProduct/update/recommendStatus?ids=${ids.join(
      ","
    )}&recommendStatus=${recommendStatus}`
  );

// 专题推荐页面数据
// /home/recommendSubject/list?pageNum=1&pageSize=5
export const recommendSubjectApi = (
  pageNum: number,
  pageSize: number
): RES<recommendSubject & { list: recommendSubjectList }> =>
  http.get(
    `/home/recommendSubject/list?pageNum=${pageNum}&pageSize=${pageSize}`
  );

// 专题是否推荐按钮
// /home/recommendSubject/update/recommendStatus
export const SubjectStatusApi = (
  ids: number,
  recommendStatus: any
): RES<RecommendStatus> =>
  http.post(
    `/home/recommendSubject/update/recommendStatus?ids=${ids}&recommendStatus=${recommendStatus}`
  );

// 是否修改排序
// /home/recommendSubject/update/sort/127?sort=111&id=127
export const SubjectUpdateApi = (
  id: number,
  sort: number
): RES<RecommendStatus> =>
  http.post(`/home/recommendSubject/update/sort/${id}?sort=${sort}&id=${id}`);

// 专题筛选搜索
// /home/recommendSubject/list?pageNum=1&pageSize=5&subjectName=%E5%A4%A7%E7%89%8C&recommendStatus=0
export const recommendSubjectSearchApi = (
  pageNum: number,
  pageSize: number,
  subjectName: string | number,
  recommendStatus: number
): RES<ProductData & { list: ProductList }> =>
  http.get(
    `/home/recommendSubject/list?pageNum=${pageNum}&pageSize=${pageSize}&subjectName=${subjectName}&recommendStatus=${recommendStatus}`
  );

// 专题推荐页面删除
// /home/recommendSubject/delete
export const SubjectDeleteApi = (ids: number): RES<DeleteData> =>
  http.post(`/home/recommendSubject/delete?ids=${ids}`);

// 专题推荐批量修改状态
// /home/recommendSubject/update/recommendStatus
export const recommendSubjectStatusAllApi = (
  ids: number[],
  recommendStatus: number | string
): RES<DeleteData> =>
  http.post(
    `/home/recommendSubject/update/recommendStatus?ids=${ids.join(
      ","
    )}&recommendStatus=${recommendStatus}`
  );

// 选择专题弹框数据
// /subject/list?pageNum=1&pageSize=5
export const TanSubjectApi = (
  pageNum: number,
  pageSize: number
): RES<ProductData & { list: ProductList }> =>
  http.get(`/subject/list?pageNum=${pageNum}&pageSize=${pageSize}`);

// 专题弹框搜索
// /subject/list?keyword=%E5%A4%8F&pageNum=1&pageSize=5
export const subjectListApi = (
  keyword: string | number,
  pageNum: number,
  pageSize: number
): RES<ProductData & { list: ProductList }> =>
  http.get(
    `/subject/list?keyword=${keyword}&pageNum=${pageNum}&pageSize=${pageSize}`
  );

// 专题推荐商品添加
// /home/recommendSubject/create
export const SubjectCreateApi = (params: any): RES<DeleteData> =>
  http.post(`/home/recommendSubject/create`, params);

// 广告列表页面数据
// /home/advertise/list?pageNum=1&pageSize=5
export const advertiseListApi = (
  pageNum: number,
  pageSize: number
): RES<advertise & { list: advertiseList }> =>
  http.get(`/home/advertise/list?pageNum=${pageNum}&pageSize=${pageSize}`);

// 广告提交数据
// /home/advertise/create
export const advertiseCreateApi = (params: advertiseCreate): RES<DeleteData> =>
  http.post(`/home/advertise/create`, params);
// 广告推荐首页查询搜索
// /home/advertise/list?pageNum=1&pageSize=5&name=%E4%BA%AC%E4%B8%9C&type=1&endTime=2023-01-10
export const advertiseSearchApi = (
  pageNum: number,
  pageSize: number,
  name: string,
  type: number,
  endTime: string | number
): RES<advertise & { list: advertiseList }> =>
  http.get(
    `/home/advertise/list?pageNum=${pageNum}&pageSize=${pageSize}&name=${name}&type=${type}&endTime=${endTime}`
  );

// 广告推荐页面批量操作之删除
// /home/advertise/delete
export const advertiseDeleteApi = (ids: number): RES<DeleteData> =>
  http.post(`/home/advertise/delete?ids=${ids}`);

// 广告推荐首页是否推荐上线下线状态
// /home/advertise/update/status/123?status=0
export const advertiseStatusApi = (
  id: number,
  status: number
): RES<RecommendStatus> =>
  http.post(`/home/advertise/update/status/${id}?status=${status}`);

// 广告编辑跳转传参
// /home/advertise/123
export const advertiseIdApi = (id: number): RES<advertiseList> =>
  http.get(`/home/advertise/${id}`);

  // 广告编辑修改提交
  // /home/advertise/update/156
  export const advertiseUpdateApi = (id:number,params: advertiseCreate): RES<DeleteData> =>
  http.post(`/home/advertise/update/${id}`, params);
